<div class="footer">
    <div class="footer-content-top container-outer">
        <div class="footer-item">
            <div class="footer-item-top">
                <div class="footer-logo"><a href="{:addon_url('wwh/index/index')}"><img src="{$site.footer_logo|cdnurl}" alt=""></a></div>
            </div>
            <div class="footer-item-bottom">
                <div class="footer-contact">
                    <li>
                        <span class="font">{$site.tel}</span>
                    </li>
                    <li>
                        <span>{:__lang('Email')}：{$site.email}</span>
                    </li>
                    <li>
                        <span>{:__lang('Address')}：{$site.address}</span>
                    </li>
                </div>
            </div>
        </div>
        <div class="footer-item">
            <div class="footer-item-top">
                <div class="footer-link">{:__lang('Link Navigation')}</div>
            </div>
            <div class="footer-item-bottom">
                <div class="footer-nav">
                    {$site.content}
                </div>
            </div>
        </div>
        <div class="footer-item">
            <div class="footer-item-top">
                <div class="footer-link">{:__lang('More Media')}</div>
            </div>
            <div class="footer-item-bottom">
                <div class="footer-social">
                    <li>
                        <a href="javascript:;" class="click-message" title="{:__lang('Customer Message')}">
                            <img src="__CDN__/assets/addons/wwh/images/message.png" class="img-center" alt="{:__lang('Customer Message')}">
                        </a>
                    </li>
                    <li>
                        <a href="{$site.weibo}" target="_blank">
                            <img src="__CDN__/assets/addons/wwh/images/weibo.png" class="img-center" alt="{:__lang('Weibo')}">
                        </a>
                    </li>
                    <li>
                        <a>
                            <img src="__CDN__/assets/addons/wwh/images/wechat.png" class="img-center" alt="{:__lang('WeChat')}">
                        </a>
                        <div class="footer-img-show"><img src="{$site.wechat|cdnurl}" class="img-center"></div>
                    </li>
                    <li>
                        <a>
                            <img src="__CDN__/assets/addons/wwh/images/douyin.png" class="img-center" alt="{:__lang('Tiktok')}">
                        </a>
                        <div class="footer-img-show"><img src="{$site.douyin|cdnurl}" class="img-center"></div>
                    </li>
                    <li>
                        <a href="javascript:;" class="return-top" title="{:__lang('Top')}">
                            <img src="__CDN__/assets/addons/wwh/images/top.png" class="img-center">
                        </a>
                    </li>
                </div>
            </div>
        </div>
    </div>
    <div class="footer-content-bottom">
        <div class="container-outer">
            <div class="footer-copy">{$site.copyright}<a href="{$site.link2}" rel="nofollow" target="_blank">{$site.beian}</a></div>
            <div class="footer-beian">
                <a href="{$site.link1}"><i><img src="__CDN__/assets/addons/wwh/images/beian.png" class="img-center"></i><span>{$site.gongwang}</span></a>
            </div>
        </div>
    </div>
</div>
<!-- 客户留言 -->
<div class="message-bg">
    <div class="message-wrapper">
        <div class="message-box">
            <form id="message" method="post">
                <div class="message-title">
                    <h5>{:__lang('Message Inquiry')}</h5>
                </div>
                <div class="message-list">
                    <div class="message-text">
                        <input type="text" placeholder="{:__lang('Please enter your name')}" name="realname" id="realname" autocomplete="on">
                    </div>
                    <div class="message-text">
                        <input type="text" placeholder="{:__lang('Please enter your phone number')}" name="tel" id="tel" autocomplete="on">
                    </div>
                    <div class="message-text">
                        <input type="text" placeholder="{:__lang('Please enter your email address')}" name="email" id="email" autocomplete="on">
                    </div>
                    <div class="message-text ht">
                        <textarea name="content" id="content" placeholder="{:__lang('The information you expect to know')}"></textarea>
                    </div>
                    <div class="verify-group">
                        <div class="message-text left">
                            <input type="text" placeholder="{:__lang('Verification Code')}" name="verify" id="verify" autocomplete="off">
                        </div>
                        <div class="verify-img right">
                            <img id="verifyImgs" src="{:addon_url('wwh/index/verify')}" onclick="this.src='{:addon_url('wwh/index/verify')}?seed='+Math.random()" />
                        </div>
                    </div>
                </div>
				{:token()}
                <div class="message-subbox clearfix">
                    <div class="message-submit">
                        <p>{:__lang('Submit')}</p>
                    </div>
                </div>
            </form>
        </div>
        <div class="message-close">
            <img src="__CDN__/assets/addons/wwh/images/guanbi1.png" alt="" class="img1">
            <img src="__CDN__/assets/addons/wwh/images/guanbi2.png" alt="" class="img2">
        </div>
    </div>
</div>
<script src="__CDN__/assets/addons/wwh/js/layer/layer.js"></script>
<script type="text/javascript">
    //客户留言
    $(".message-submit").click(function(){
        var form = document.getElementById("message");
        var formdata = new FormData(form);

        var realname=$.trim($("#realname").val());
        var tel=$.trim($("#tel").val());
        var email=$.trim($("#email").val());
        var content=$.trim($("#content").val());
        var verify=$.trim($("#verify").val());

        // 验证逻辑
        if(!realname){showError('{:__lang(\'Please fill in your name\')}');return false;}
        if(!tel){showError('{:__lang(\'Please provide your phone number\')}');return false;}
        if(!/^1[3-9]\d{9}$/.test(tel)){showError('{:__lang(\'Please provide a valid phone number\')}');return false;}
        if(!email){showError('{:__lang(\'Please fill in your email address\')}');return false;}
        if(!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email)){showError('{:__lang(\'Please provide a valid email address\')}');return false;}
        if(!content){showError('{:__lang(\'Please fill in the message content\')}');return false;}
        if(!verify){showError('{:__lang(\'Please fill in the verification code\')}');return false;}

        // 显示加载状态
        $(this).prop('disabled', true);

        $.ajax({
            url: "{:addon_url('wwh/index/message')}",
            type: "POST",
            data: formdata,
            cache: false,
            contentType: false,
            processData: false,
            dataType: "json",
            complete: function() {
                $(".message-submit").prop('disabled', false);
            },
            success: function(response){
                if(response.code === 1){
                    layer.alert(response.msg, {
                        icon: 1,
                        end: function(){
                            window.location.reload();
                        }
                    });
                } else {
                    showError(response.msg);
                    fleshVerify();
                }
            },
            error: function() {
                showError('{:__lang(\'Network error, please try again\')}');
                fleshVerify();
            }
        });

        // 统一错误显示
        function showError(msg) {
            layer.alert(msg, {
                skin: 'layui-layer-lan',
                closeBtn: 0,
                title: "{:__lang(\'Tips\')}：",
                icon: 2,
                anim: 2
            });
        }

        //重载验证码
        function fleshVerify(){
            $('#verifyImgs').attr('src','{:addon_url('wwh/index/verify')}?seed='+Math.random());
        }

        return false;
    });
</script>
